<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.9.1"/>
<title>ht&#39;s Scheme Interpreter: tokenizer.cpp Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
  $(window).load(resizeHeight);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { init_search(); });
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td style="padding-left: 0.5em;">
   <div id="projectname">ht&#39;s Scheme Interpreter
   &#160;<span id="projectnumber">1.0</span>
   </div>
   <div id="projectbrief">a simplified scheme interpreter implementation</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.9.1 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>File&#160;Members</span></a></li>
    </ul>
  </div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('tokenizer_8cpp_source.html','');});
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="headertitle">
<div class="title">tokenizer.cpp</div>  </div>
</div><!--header-->
<div class="contents">
<a href="tokenizer_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;<span class="preprocessor">#</span><span class="preprocessor">include</span> <a class="code" href="tokenizer_8hpp.html">&quot;tokenizer.hpp&quot;</a></div>
<div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;<span class="preprocessor">#</span><span class="preprocessor">include</span> <a class="code" href="types_8hpp.html">&quot;types.hpp&quot;</a></div>
<div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;<span class="preprocessor">#</span><span class="preprocessor">include</span> <span class="preprocessor">&lt;</span><span class="preprocessor">string</span><span class="preprocessor">&gt;</span></div>
<div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160;<span class="preprocessor">#</span><span class="preprocessor">include</span> <span class="preprocessor">&lt;</span><span class="preprocessor">vector</span><span class="preprocessor">&gt;</span></div>
<div class="line"><a name="l00005"></a><span class="lineno">    5</span>&#160;<span class="preprocessor">#</span><span class="preprocessor">include</span> <span class="preprocessor">&lt;</span><span class="preprocessor">list</span><span class="preprocessor">&gt;</span></div>
<div class="line"><a name="l00006"></a><span class="lineno">    6</span>&#160;<span class="preprocessor">#</span><span class="preprocessor">include</span> <span class="preprocessor">&lt;</span><span class="preprocessor">cstddef</span><span class="preprocessor">&gt;</span></div>
<div class="line"><a name="l00007"></a><span class="lineno">    7</span>&#160;<span class="preprocessor">#</span><span class="preprocessor">include</span> <span class="preprocessor">&lt;</span><span class="preprocessor">algorithm</span><span class="preprocessor">&gt;</span></div>
<div class="line"><a name="l00008"></a><span class="lineno">    8</span>&#160;<span class="preprocessor">#</span><span class="preprocessor">include</span> <span class="preprocessor">&lt;</span><span class="preprocessor">iostream</span><span class="preprocessor">&gt;</span></div>
<div class="line"><a name="l00009"></a><span class="lineno">    9</span>&#160;</div>
<div class="line"><a name="l00010"></a><span class="lineno">   10</span>&#160;<span class="keyword">namespace</span></div>
<div class="line"><a name="l00011"></a><span class="lineno">   11</span>&#160;{</div>
<div class="line"><a name="l00012"></a><span class="lineno">   12</span>&#160;    <span class="keyword">inline</span> <span class="keywordtype">bool</span> notSpecialChar(<span class="keyword">const</span> std::string&amp; s, size_t pos) { <span class="keywordflow">return</span> pos&lt;2 || s[pos-1]!=<span class="stringliteral">&#39;#&#39;</span> || s[pos-2]!=<span class="stringliteral">&#39;\\&#39;</span>; }</div>
<div class="line"><a name="l00013"></a><span class="lineno">   13</span>&#160;    <span class="keyword">inline</span> <span class="keywordtype">bool</span> isChar(<span class="keyword">const</span> std::string&amp; s, size_t pos, <span class="keywordtype">char</span> c) { <span class="keywordflow">return</span> s[pos]==c &amp;&amp; notSpecialChar(s, pos); }</div>
<div class="line"><a name="l00014"></a><span class="lineno">   14</span>&#160;    <span class="keyword">inline</span> std::string char2Str(<span class="keywordtype">char</span> c) { std::string s; s.push_back(c); <span class="keywordflow">return</span> s; }</div>
<div class="line"><a name="l00015"></a><span class="lineno">   15</span>&#160;    <span class="keyword">inline</span> <span class="keywordtype">bool</span> cond( <span class="keyword">const</span> std::string&amp; s) { <span class="keywordflow">return</span> !s.size(); }</div>
<div class="line"><a name="l00016"></a><span class="lineno">   16</span>&#160;}</div>
<div class="line"><a name="l00017"></a><span class="lineno">   17</span>&#160;</div>
<div class="line"><a name="l00018"></a><span class="lineno"><a class="line" href="class_tokenizer.html#a2a6c04ea8c784f66bebcb6df7073769c">   18</a></span>&#160;<a class="code" href="class_tokenizer.html">Tokenizer</a>::<a class="code" href="class_tokenizer.html#a2a6c04ea8c784f66bebcb6df7073769c">Tokenizer</a>()</div>
<div class="line"><a name="l00019"></a><span class="lineno">   19</span>&#160;{ }</div>
<div class="line"><a name="l00020"></a><span class="lineno">   20</span>&#160;</div>
<div class="line"><a name="l00021"></a><span class="lineno"><a class="line" href="class_tokenizer.html#a6edc9ba4af94d2aa55f48a83c903800f">   21</a></span>&#160;<a class="code" href="class_tokenizer.html">Tokenizer</a>::<a class="code" href="class_tokenizer.html#a6edc9ba4af94d2aa55f48a83c903800f">Tokenizer</a>(<span class="keyword">const</span> std::vector&lt;std::string&gt;&amp; lines)</div>
<div class="line"><a name="l00022"></a><span class="lineno">   22</span>&#160;{</div>
<div class="line"><a name="l00023"></a><span class="lineno">   23</span>&#160;    <a class="code" href="class_tokenizer.html#a8bd8a4eb5df764f6128028daa0e9044b">split</a><a class="code" href="class_tokenizer.html#a8bd8a4eb5df764f6128028daa0e9044b">(</a>lines<a class="code" href="class_tokenizer.html#a8bd8a4eb5df764f6128028daa0e9044b">)</a>;</div>
<div class="line"><a name="l00024"></a><span class="lineno">   24</span>&#160;    <a class="code" href="class_tokenizer.html#ae928efe72c00908a3529747b4cfd01d5">parse</a><a class="code" href="class_tokenizer.html#ae928efe72c00908a3529747b4cfd01d5">(</a><a class="code" href="class_tokenizer.html#a89707ad3a758fc9ec58f00d92d5fc622">rawTokens</a><a class="code" href="class_tokenizer.html#ae928efe72c00908a3529747b4cfd01d5">)</a>;</div>
<div class="line"><a name="l00025"></a><span class="lineno">   25</span>&#160;}</div>
<div class="line"><a name="l00026"></a><span class="lineno">   26</span>&#160;</div>
<div class="line"><a name="l00027"></a><span class="lineno"><a class="line" href="class_tokenizer.html#a8bd8a4eb5df764f6128028daa0e9044b">   27</a></span>&#160;<span class="keywordtype">void</span> <a class="code" href="class_tokenizer.html">Tokenizer</a>::<a class="code" href="class_tokenizer.html#a8bd8a4eb5df764f6128028daa0e9044b">split</a>(<span class="keyword">const</span> std::vector&lt;std::string&gt;&amp; lines)</div>
<div class="line"><a name="l00028"></a><span class="lineno">   28</span>&#160;{</div>
<div class="line"><a name="l00029"></a><span class="lineno">   29</span>&#160;    <span class="keywordtype">bool</span> inStr = <span class="keyword">false</span>;</div>
<div class="line"><a name="l00030"></a><span class="lineno">   30</span>&#160;    <a class="code" href="class_tokenizer.html#a330a4cce0cbf3ebfbe601d97022d1ed4">complete</a> = <span class="keyword">true</span>;</div>
<div class="line"><a name="l00031"></a><span class="lineno">   31</span>&#160;    <a class="code" href="class_tokenizer.html#a89707ad3a758fc9ec58f00d92d5fc622">rawTokens</a>.clear();</div>
<div class="line"><a name="l00032"></a><span class="lineno">   32</span>&#160;    <a class="code" href="class_tokenizer.html#a89707ad3a758fc9ec58f00d92d5fc622">rawTokens</a>.push_back(<span class="stringliteral">&quot;&quot;</span>);</div>
<div class="line"><a name="l00033"></a><span class="lineno">   33</span>&#160;    <span class="keywordflow">for</span> (size_t i=0; i&lt;lines.size(); ++i)</div>
<div class="line"><a name="l00034"></a><span class="lineno">   34</span>&#160;    {</div>
<div class="line"><a name="l00035"></a><span class="lineno">   35</span>&#160;        size_t pos=0;</div>
<div class="line"><a name="l00036"></a><span class="lineno">   36</span>&#160;        <span class="comment">//std::cout&lt;&lt;&quot; begin of &quot;&lt;&lt;i&lt;&lt;&quot; &quot;&lt;&lt;inStr&lt;&lt;std::endl;</span></div>
<div class="line"><a name="l00037"></a><span class="lineno">   37</span>&#160;        <span class="keywordflow">while</span> (<span class="keyword">true</span>)</div>
<div class="line"><a name="l00038"></a><span class="lineno">   38</span>&#160;        {</div>
<div class="line"><a name="l00039"></a><span class="lineno">   39</span>&#160;            <span class="keywordflow">if</span> (pos&gt;=lines[i].length())</div>
<div class="line"><a name="l00040"></a><span class="lineno">   40</span>&#160;              <span class="keywordflow">break</span>;</div>
<div class="line"><a name="l00041"></a><span class="lineno">   41</span>&#160;            <span class="keywordflow">if</span> (inStr)</div>
<div class="line"><a name="l00042"></a><span class="lineno">   42</span>&#160;            {</div>
<div class="line"><a name="l00043"></a><span class="lineno">   43</span>&#160;                <span class="keywordflow">while</span>(pos&lt;lines[i].size() &amp;&amp; !isChar(lines[i], pos, <span class="stringliteral">&#39;&quot;&#39;</span>))</div>
<div class="line"><a name="l00044"></a><span class="lineno">   44</span>&#160;                  <a class="code" href="class_tokenizer.html#a89707ad3a758fc9ec58f00d92d5fc622">rawTokens</a>.rbegin() -&gt; push_back(lines[i][pos++]);</div>
<div class="line"><a name="l00045"></a><span class="lineno">   45</span>&#160;                <span class="keywordflow">if</span> (pos&lt;lines[i].size())</div>
<div class="line"><a name="l00046"></a><span class="lineno">   46</span>&#160;                {</div>
<div class="line"><a name="l00047"></a><span class="lineno">   47</span>&#160;                    <a class="code" href="class_tokenizer.html#a89707ad3a758fc9ec58f00d92d5fc622">rawTokens</a>.rbegin() -&gt; push_back(<span class="stringliteral">&#39;&quot;&#39;</span>);</div>
<div class="line"><a name="l00048"></a><span class="lineno">   48</span>&#160;                    inStr = <span class="keyword">false</span>;</div>
<div class="line"><a name="l00049"></a><span class="lineno">   49</span>&#160;                    <a class="code" href="class_tokenizer.html#a89707ad3a758fc9ec58f00d92d5fc622">rawTokens</a>.push_back(<span class="stringliteral">&quot;&quot;</span>);</div>
<div class="line"><a name="l00050"></a><span class="lineno">   50</span>&#160;                    ++pos;</div>
<div class="line"><a name="l00051"></a><span class="lineno">   51</span>&#160;                }</div>
<div class="line"><a name="l00052"></a><span class="lineno">   52</span>&#160;            }</div>
<div class="line"><a name="l00053"></a><span class="lineno">   53</span>&#160;            <span class="keywordflow">else</span></div>
<div class="line"><a name="l00054"></a><span class="lineno">   54</span>&#160;            {</div>
<div class="line"><a name="l00055"></a><span class="lineno">   55</span>&#160;</div>
<div class="line"><a name="l00056"></a><span class="lineno">   56</span>&#160;                <span class="keywordflow">while</span> (pos&lt;lines[i].length() &amp;&amp; (lines[i][pos]==<span class="stringliteral">&#39; &#39;</span> || lines[i][pos]==<span class="stringliteral">&#39;\t&#39;</span>))</div>
<div class="line"><a name="l00057"></a><span class="lineno">   57</span>&#160;                  ++pos;</div>
<div class="line"><a name="l00058"></a><span class="lineno">   58</span>&#160;                size_t until = std::min( lines[i].find(<span class="stringliteral">&#39; &#39;</span>, pos), lines[i].find(<span class="stringliteral">&#39;\t&#39;</span>, pos));</div>
<div class="line"><a name="l00059"></a><span class="lineno">   59</span>&#160;                std::string t;</div>
<div class="line"><a name="l00060"></a><span class="lineno">   60</span>&#160;                <span class="keywordflow">if</span> (until == lines[i].npos)</div>
<div class="line"><a name="l00061"></a><span class="lineno">   61</span>&#160;                  t=lines[i].substr(pos);</div>
<div class="line"><a name="l00062"></a><span class="lineno">   62</span>&#160;                <span class="keywordflow">else</span></div>
<div class="line"><a name="l00063"></a><span class="lineno">   63</span>&#160;                  t=lines[i].substr(pos, until-pos);</div>
<div class="line"><a name="l00064"></a><span class="lineno">   64</span>&#160;</div>
<div class="line"><a name="l00065"></a><span class="lineno">   65</span>&#160;                <span class="comment">//std::cout&lt;&lt; &quot;LOG: big token |&quot;&lt;&lt;t&lt;&lt;&quot;| from &quot;&lt;&lt;pos &lt;&lt;&quot; to &quot;&lt;&lt;until&lt;&lt;&quot;  instr:&quot;&lt;&lt;inStr&lt;&lt;std::endl;</span></div>
<div class="line"><a name="l00066"></a><span class="lineno">   66</span>&#160;                pos = until;</div>
<div class="line"><a name="l00067"></a><span class="lineno">   67</span>&#160;</div>
<div class="line"><a name="l00068"></a><span class="lineno">   68</span>&#160;                <span class="keywordflow">if</span> (t!=<span class="stringliteral">&quot;&quot;</span>)</div>
<div class="line"><a name="l00069"></a><span class="lineno">   69</span>&#160;                  <span class="keywordflow">for</span>(size_t j=0; j&lt;t.size(); ++j)</div>
<div class="line"><a name="l00070"></a><span class="lineno">   70</span>&#160;                  {</div>
<div class="line"><a name="l00071"></a><span class="lineno">   71</span>&#160;                      <span class="keywordflow">if</span> (inStr)</div>
<div class="line"><a name="l00072"></a><span class="lineno">   72</span>&#160;                      {</div>
<div class="line"><a name="l00073"></a><span class="lineno">   73</span>&#160;                          <a class="code" href="class_tokenizer.html#a89707ad3a758fc9ec58f00d92d5fc622">rawTokens</a>.rbegin() -&gt; push_back(t[j]);</div>
<div class="line"><a name="l00074"></a><span class="lineno">   74</span>&#160;                          <span class="keywordflow">if</span> (isChar(t, j, <span class="stringliteral">&#39;&quot;&#39;</span>))</div>
<div class="line"><a name="l00075"></a><span class="lineno">   75</span>&#160;                            inStr = <span class="keyword">false</span>;</div>
<div class="line"><a name="l00076"></a><span class="lineno">   76</span>&#160;                      } <span class="keywordflow">else</span></div>
<div class="line"><a name="l00077"></a><span class="lineno">   77</span>&#160;                      {</div>
<div class="line"><a name="l00078"></a><span class="lineno">   78</span>&#160;                          <span class="keywordflow">if</span> (isChar(t, j, <span class="stringliteral">&#39;(&#39;</span>) || isChar(t, j, <span class="stringliteral">&#39;)&#39;</span>))</div>
<div class="line"><a name="l00079"></a><span class="lineno">   79</span>&#160;                          {</div>
<div class="line"><a name="l00080"></a><span class="lineno">   80</span>&#160;                              <a class="code" href="class_tokenizer.html#a89707ad3a758fc9ec58f00d92d5fc622">rawTokens</a>.push_back(char2Str(t[j]));</div>
<div class="line"><a name="l00081"></a><span class="lineno">   81</span>&#160;                              <a class="code" href="class_tokenizer.html#a89707ad3a758fc9ec58f00d92d5fc622">rawTokens</a>.push_back(<span class="stringliteral">&quot;&quot;</span>);</div>
<div class="line"><a name="l00082"></a><span class="lineno">   82</span>&#160;                          }</div>
<div class="line"><a name="l00083"></a><span class="lineno">   83</span>&#160;                          <span class="keywordflow">else</span> <span class="keywordflow">if</span> (isChar(t, j, <span class="stringliteral">&#39;&quot;&#39;</span>))</div>
<div class="line"><a name="l00084"></a><span class="lineno">   84</span>&#160;                          {</div>
<div class="line"><a name="l00085"></a><span class="lineno">   85</span>&#160;                              <a class="code" href="class_tokenizer.html#a89707ad3a758fc9ec58f00d92d5fc622">rawTokens</a>.push_back(char2Str(t[j]));</div>
<div class="line"><a name="l00086"></a><span class="lineno">   86</span>&#160;                              inStr = <span class="keyword">true</span>;</div>
<div class="line"><a name="l00087"></a><span class="lineno">   87</span>&#160;                          }</div>
<div class="line"><a name="l00088"></a><span class="lineno">   88</span>&#160;                          <span class="keywordflow">else</span></div>
<div class="line"><a name="l00089"></a><span class="lineno">   89</span>&#160;                            <a class="code" href="class_tokenizer.html#a89707ad3a758fc9ec58f00d92d5fc622">rawTokens</a>.rbegin() -&gt; push_back(t[j]);</div>
<div class="line"><a name="l00090"></a><span class="lineno">   90</span>&#160;                      }</div>
<div class="line"><a name="l00091"></a><span class="lineno">   91</span>&#160;</div>
<div class="line"><a name="l00092"></a><span class="lineno">   92</span>&#160;                  }</div>
<div class="line"><a name="l00093"></a><span class="lineno">   93</span>&#160;</div>
<div class="line"><a name="l00094"></a><span class="lineno">   94</span>&#160;                <span class="keywordflow">if</span> (!inStr)<a class="code" href="class_tokenizer.html#a89707ad3a758fc9ec58f00d92d5fc622">rawTokens</a>.push_back(<span class="stringliteral">&quot;&quot;</span>);</div>
<div class="line"><a name="l00095"></a><span class="lineno">   95</span>&#160;            } <span class="comment">//if (inStr) else</span></div>
<div class="line"><a name="l00096"></a><span class="lineno">   96</span>&#160;        } <span class="comment">//while</span></div>
<div class="line"><a name="l00097"></a><span class="lineno">   97</span>&#160;        <span class="keywordflow">if</span> (inStr) <a class="code" href="class_tokenizer.html#a89707ad3a758fc9ec58f00d92d5fc622">rawTokens</a>.rbegin() -&gt; push_back(<span class="stringliteral">&#39;\n&#39;</span>); <span class="keywordflow">else</span> <a class="code" href="class_tokenizer.html#a89707ad3a758fc9ec58f00d92d5fc622">rawTokens</a>.push_back(<span class="stringliteral">&quot;&quot;</span>);</div>
<div class="line"><a name="l00098"></a><span class="lineno">   98</span>&#160;    } <span class="comment">//for</span></div>
<div class="line"><a name="l00099"></a><span class="lineno">   99</span>&#160;    <a class="code" href="class_tokenizer.html#a330a4cce0cbf3ebfbe601d97022d1ed4">complete</a> &amp;= !inStr;</div>
<div class="line"><a name="l00100"></a><span class="lineno">  100</span>&#160;    <a class="code" href="class_tokenizer.html#a89707ad3a758fc9ec58f00d92d5fc622">rawTokens</a>.remove_if(cond);</div>
<div class="line"><a name="l00101"></a><span class="lineno">  101</span>&#160;</div>
<div class="line"><a name="l00102"></a><span class="lineno">  102</span>&#160;}<span class="comment">//function</span></div>
<div class="line"><a name="l00103"></a><span class="lineno">  103</span>&#160;</div>
<div class="line"><a name="l00104"></a><span class="lineno"><a class="line" href="class_tokenizer.html#ae928efe72c00908a3529747b4cfd01d5">  104</a></span>&#160;<span class="keywordtype">void</span> <a class="code" href="class_tokenizer.html">Tokenizer</a>::<a class="code" href="class_tokenizer.html#ae928efe72c00908a3529747b4cfd01d5">parse</a>(<span class="keyword">const</span> std::list&lt;std::string&gt; &amp; rawTokens)</div>
<div class="line"><a name="l00105"></a><span class="lineno">  105</span>&#160;{</div>
<div class="line"><a name="l00106"></a><span class="lineno">  106</span>&#160;    <span class="keywordflow">if</span> (!<a class="code" href="class_tokenizer.html#a330a4cce0cbf3ebfbe601d97022d1ed4">complete</a>) <span class="keywordflow">return</span>;</div>
<div class="line"><a name="l00107"></a><span class="lineno">  107</span>&#160;    <a class="code" href="class_tokenizer.html#ae547093dbd03b3e70373147e4669d9fa">tokens</a>.clear();</div>
<div class="line"><a name="l00108"></a><span class="lineno">  108</span>&#160;    <span class="keywordtype">int</span> dep = 0;</div>
<div class="line"><a name="l00109"></a><span class="lineno">  109</span>&#160;    <a class="code" href="struct_parser_visitor.html">ParserVisitor</a> parserVisitor;</div>
<div class="line"><a name="l00110"></a><span class="lineno">  110</span>&#160;    for_each(rawTokens.begin(), rawTokens.end(), [&amp;](<span class="keyword">const</span> std::string&amp; rawToken)</div>
<div class="line"><a name="l00111"></a><span class="lineno">  111</span>&#160;                {</div>
<div class="line"><a name="l00112"></a><span class="lineno">  112</span>&#160;                parserVisitor<a class="code" href="struct_parser_visitor.html#a241c6d04c5a0e736ee477d5d93af8ac7">.</a><a class="code" href="struct_parser_visitor.html#a241c6d04c5a0e736ee477d5d93af8ac7">parse</a><a class="code" href="struct_parser_visitor.html#a241c6d04c5a0e736ee477d5d93af8ac7">(</a>rawToken<a class="code" href="struct_parser_visitor.html#a241c6d04c5a0e736ee477d5d93af8ac7">)</a>;</div>
<div class="line"><a name="l00113"></a><span class="lineno">  113</span>&#160;                <span class="keywordflow">if</span> (!parserVisitor<a class="code" href="struct_parser_visitor.html#af5c2d247a1ec646aded499e01ca71553">.</a><a class="code" href="struct_parser_visitor.html#af5c2d247a1ec646aded499e01ca71553">ok</a>) <span class="keywordflow">throw</span> std::runtime_error(<span class="stringliteral">&quot;unrecognized token: `&quot;</span>+rawToken+<span class="stringliteral">&quot;`&quot;</span>);</div>
<div class="line"><a name="l00114"></a><span class="lineno">  114</span>&#160;                <a class="code" href="struct_token.html">Token</a> token;</div>
<div class="line"><a name="l00115"></a><span class="lineno">  115</span>&#160;                token<a class="code" href="struct_token.html#a3d2b3146021ae2acd9e1b33bf5e59c78">.</a><a class="code" href="struct_token.html#a3d2b3146021ae2acd9e1b33bf5e59c78">tokenType</a> = parserVisitor<a class="code" href="struct_parser_visitor.html#acaa4d8ca1662ec314ae2a8f048f6aca3">.</a><a class="code" href="struct_parser_visitor.html#acaa4d8ca1662ec314ae2a8f048f6aca3">tokenType</a>;</div>
<div class="line"><a name="l00116"></a><span class="lineno">  116</span>&#160;                token<a class="code" href="struct_token.html#a4c338f6ca199f4a8575e877d36d03a06">.</a><a class="code" href="struct_token.html#a4c338f6ca199f4a8575e877d36d03a06">info</a> = parserVisitor<a class="code" href="struct_parser_visitor.html#a44159efad79cb74d477675367d8dcc3f">.</a><a class="code" href="struct_parser_visitor.html#a44159efad79cb74d477675367d8dcc3f">info</a>;</div>
<div class="line"><a name="l00117"></a><span class="lineno">  117</span>&#160;                token<a class="code" href="struct_token.html#ad77981ec051c2380c38459f8c4392dad">.</a><a class="code" href="struct_token.html#ad77981ec051c2380c38459f8c4392dad">raw</a> = rawToken;</div>
<div class="line"><a name="l00118"></a><span class="lineno">  118</span>&#160;                <a class="code" href="class_tokenizer.html#ae547093dbd03b3e70373147e4669d9fa">tokens</a>.push_back(token);</div>
<div class="line"><a name="l00119"></a><span class="lineno">  119</span>&#160;                <span class="keywordflow">if</span> (token<a class="code" href="struct_token.html#a3d2b3146021ae2acd9e1b33bf5e59c78">.</a><a class="code" href="struct_token.html#a3d2b3146021ae2acd9e1b33bf5e59c78">tokenType</a> == <a class="code" href="types_2arch_8hpp.html#aa520fbf142ba1e7e659590c07da31921a0e229922772e1ebbe231bb76b1d0674e">LeftParenthesis</a>) ++dep;</div>
<div class="line"><a name="l00120"></a><span class="lineno">  120</span>&#160;                <span class="keywordflow">if</span> (token<a class="code" href="struct_token.html#a3d2b3146021ae2acd9e1b33bf5e59c78">.</a><a class="code" href="struct_token.html#a3d2b3146021ae2acd9e1b33bf5e59c78">tokenType</a> == <a class="code" href="types_2arch_8hpp.html#aa520fbf142ba1e7e659590c07da31921aa6ae499ba91edf718de60cefdb91e070">RightParenthesis</a>) --dep;</div>
<div class="line"><a name="l00121"></a><span class="lineno">  121</span>&#160;                }</div>
<div class="line"><a name="l00122"></a><span class="lineno">  122</span>&#160;            );</div>
<div class="line"><a name="l00123"></a><span class="lineno">  123</span>&#160;    <a class="code" href="class_tokenizer.html#a330a4cce0cbf3ebfbe601d97022d1ed4">complete</a> &amp;= (dep==0);</div>
<div class="line"><a name="l00124"></a><span class="lineno">  124</span>&#160;}</div>
<div class="ttc" id="class_tokenizer_html_ae928efe72c00908a3529747b4cfd01d5"><div class="ttname"><a href="class_tokenizer.html#ae928efe72c00908a3529747b4cfd01d5">Tokenizer::parse</a></div><div class="ttdeci">void parse(const std::list&lt; std::string &gt; &amp;rawTokens)</div><div class="ttdef"><b>Definition:</b> <a href="tokenizer_8cpp_source.html#l00104">tokenizer.cpp:104</a></div></div>
<div class="ttc" id="struct_token_html_a3d2b3146021ae2acd9e1b33bf5e59c78"><div class="ttname"><a href="struct_token.html#a3d2b3146021ae2acd9e1b33bf5e59c78">Token::tokenType</a></div><div class="ttdeci">TokenType tokenType</div><div class="ttdef"><b>Definition:</b> <a href="types_2all_8hpp_source.html#l00043">all.hpp:43</a></div></div>
<div class="ttc" id="struct_token_html_ad77981ec051c2380c38459f8c4392dad"><div class="ttname"><a href="struct_token.html#ad77981ec051c2380c38459f8c4392dad">Token::raw</a></div><div class="ttdeci">std::string raw</div><div class="ttdef"><b>Definition:</b> <a href="types_2all_8hpp_source.html#l00045">all.hpp:45</a></div></div>
<div class="ttc" id="types_2arch_8hpp_html_aa520fbf142ba1e7e659590c07da31921aa6ae499ba91edf718de60cefdb91e070"><div class="ttname"><a href="types_2arch_8hpp.html#aa520fbf142ba1e7e659590c07da31921aa6ae499ba91edf718de60cefdb91e070">RightParenthesis</a></div><div class="ttdef"><b>Definition:</b> <a href="types_2arch_8hpp_source.html#l00020">arch.hpp:20</a></div></div>
<div class="ttc" id="struct_parser_visitor_html_af5c2d247a1ec646aded499e01ca71553"><div class="ttname"><a href="struct_parser_visitor.html#af5c2d247a1ec646aded499e01ca71553">ParserVisitor::ok</a></div><div class="ttdeci">bool ok</div><div class="ttdef"><b>Definition:</b> <a href="types_2all_8hpp_source.html#l00050">all.hpp:50</a></div></div>
<div class="ttc" id="types_2arch_8hpp_html_aa520fbf142ba1e7e659590c07da31921a0e229922772e1ebbe231bb76b1d0674e"><div class="ttname"><a href="types_2arch_8hpp.html#aa520fbf142ba1e7e659590c07da31921a0e229922772e1ebbe231bb76b1d0674e">LeftParenthesis</a></div><div class="ttdef"><b>Definition:</b> <a href="types_2arch_8hpp_source.html#l00019">arch.hpp:19</a></div></div>
<div class="ttc" id="struct_parser_visitor_html_a44159efad79cb74d477675367d8dcc3f"><div class="ttname"><a href="struct_parser_visitor.html#a44159efad79cb74d477675367d8dcc3f">ParserVisitor::info</a></div><div class="ttdeci">InfoTypes info</div><div class="ttdef"><b>Definition:</b> <a href="types_2all_8hpp_source.html#l00053">all.hpp:53</a></div></div>
<div class="ttc" id="class_tokenizer_html_a2a6c04ea8c784f66bebcb6df7073769c"><div class="ttname"><a href="class_tokenizer.html#a2a6c04ea8c784f66bebcb6df7073769c">Tokenizer::Tokenizer</a></div><div class="ttdeci">Tokenizer()</div><div class="ttdef"><b>Definition:</b> <a href="tokenizer_8cpp_source.html#l00018">tokenizer.cpp:18</a></div></div>
<div class="ttc" id="class_tokenizer_html_a6edc9ba4af94d2aa55f48a83c903800f"><div class="ttname"><a href="class_tokenizer.html#a6edc9ba4af94d2aa55f48a83c903800f">Tokenizer::Tokenizer</a></div><div class="ttdeci">Tokenizer(const std::vector&lt; std::string &gt; &amp;lines)</div><div class="ttdef"><b>Definition:</b> <a href="tokenizer_8cpp_source.html#l00021">tokenizer.cpp:21</a></div></div>
<div class="ttc" id="class_tokenizer_html_a8bd8a4eb5df764f6128028daa0e9044b"><div class="ttname"><a href="class_tokenizer.html#a8bd8a4eb5df764f6128028daa0e9044b">Tokenizer::split</a></div><div class="ttdeci">void split(const std::vector&lt; std::string &gt; &amp;lines)</div><div class="ttdef"><b>Definition:</b> <a href="tokenizer_8cpp_source.html#l00027">tokenizer.cpp:27</a></div></div>
<div class="ttc" id="class_tokenizer_html"><div class="ttname"><a href="class_tokenizer.html">Tokenizer</a></div><div class="ttdef"><b>Definition:</b> <a href="tokenizer_8hpp_source.html#l00007">tokenizer.hpp:7</a></div></div>
<div class="ttc" id="class_tokenizer_html_a89707ad3a758fc9ec58f00d92d5fc622"><div class="ttname"><a href="class_tokenizer.html#a89707ad3a758fc9ec58f00d92d5fc622">Tokenizer::rawTokens</a></div><div class="ttdeci">std::list&lt; std::string &gt; rawTokens</div><div class="ttdef"><b>Definition:</b> <a href="tokenizer_8hpp_source.html#l00014">tokenizer.hpp:14</a></div></div>
<div class="ttc" id="struct_parser_visitor_html_acaa4d8ca1662ec314ae2a8f048f6aca3"><div class="ttname"><a href="struct_parser_visitor.html#acaa4d8ca1662ec314ae2a8f048f6aca3">ParserVisitor::tokenType</a></div><div class="ttdeci">TokenType tokenType</div><div class="ttdef"><b>Definition:</b> <a href="types_2all_8hpp_source.html#l00052">all.hpp:52</a></div></div>
<div class="ttc" id="struct_token_html_a4c338f6ca199f4a8575e877d36d03a06"><div class="ttname"><a href="struct_token.html#a4c338f6ca199f4a8575e877d36d03a06">Token::info</a></div><div class="ttdeci">InfoTypes info</div><div class="ttdef"><b>Definition:</b> <a href="types_2all_8hpp_source.html#l00044">all.hpp:44</a></div></div>
<div class="ttc" id="struct_parser_visitor_html"><div class="ttname"><a href="struct_parser_visitor.html">ParserVisitor</a></div><div class="ttdef"><b>Definition:</b> <a href="types_2all_8hpp_source.html#l00048">all.hpp:48</a></div></div>
<div class="ttc" id="class_tokenizer_html_ae547093dbd03b3e70373147e4669d9fa"><div class="ttname"><a href="class_tokenizer.html#ae547093dbd03b3e70373147e4669d9fa">Tokenizer::tokens</a></div><div class="ttdeci">std::list&lt; Token &gt; tokens</div><div class="ttdef"><b>Definition:</b> <a href="tokenizer_8hpp_source.html#l00015">tokenizer.hpp:15</a></div></div>
<div class="ttc" id="struct_token_html"><div class="ttname"><a href="struct_token.html">Token</a></div><div class="ttdef"><b>Definition:</b> <a href="types_2all_8hpp_source.html#l00041">all.hpp:41</a></div></div>
<div class="ttc" id="class_tokenizer_html_a330a4cce0cbf3ebfbe601d97022d1ed4"><div class="ttname"><a href="class_tokenizer.html#a330a4cce0cbf3ebfbe601d97022d1ed4">Tokenizer::complete</a></div><div class="ttdeci">bool complete</div><div class="ttdef"><b>Definition:</b> <a href="tokenizer_8hpp_source.html#l00016">tokenizer.hpp:16</a></div></div>
<div class="ttc" id="struct_parser_visitor_html_a241c6d04c5a0e736ee477d5d93af8ac7"><div class="ttname"><a href="struct_parser_visitor.html#a241c6d04c5a0e736ee477d5d93af8ac7">ParserVisitor::parse</a></div><div class="ttdeci">void parse(const string &amp;token_)</div><div class="ttdef"><b>Definition:</b> <a href="types_2all_8cpp_source.html#l00003">all.cpp:3</a></div></div>
</div><!-- fragment --></div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="navelem"><a class="el" href="tokenizer_8cpp.html">tokenizer.cpp</a></li>
    <li class="footer">Generated by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.9.1 </li>
  </ul>
</div>
</body>
</html>
